{% load i18n %}
{% load core_tags %}
{% load privacy_tags %}
{% load gravatar %}
{% load projects_tags %}

<div id="project_details">
  <div class="wrapper">

<div class="module">
  {% if onboard %}
  <!-- BEGIN onboard -->
    {% include 'projects/onboard_detail.html' %}
  <!-- END onboard -->
  {% endif %}


  <div class="module-header">
    <h3>{% trans "Versions" %}</h3>
  </div>

  <div class="module-list">

    <div class="module-list-wrapper">
      <ul>
      {% for version in versions|sort_version_aware %}
        <li class="module-item col-span">
        {% if version.uploaded or version.built %}
          {# Link to the docs #}
          <a class="module-item-title" href="{{ version.get_absolute_url }}">
            {{ version.slug }}
          {% if request.user in project.users.all %}
            <span class="right-menu quiet">{{ version.get_privacy_level_display }}</span>
          {% endif %}
          </a>
        {% else %}
          <a class="module-item-title" href="{{ version.project.get_builds_url }}">
            {{ version.slug }}
          </a>
        {% endif %}
          {% if request.user|is_admin:project %}
            <ul class="module-item-menu">
              <li><a href="{% url "project_version_detail" project.slug version.slug %}">{% trans "Edit" %}</a></li>
            </ul>
          {% endif %}
        </li>

      {% empty %}
        <li class="module-item">
          <p class="quiet">
            {% trans "No active versions." %}
          </p>
        </li>
      {% endfor %}
      </ul>
    </div>
  </div>

{% block build_versions %}
{% if versions and request.user|is_admin:project %}
  <div class="build_a_version">
    <h3>{% trans "Build a version" %}</h3>
    <div class="version_right">
      <form method="post" action="{% url "projects_detail" project.slug %}">
        {% csrf_token %}
        <select id="id_version" name="version_slug">
        {% for version in versions|sort_version_aware %}
          <option value="{{ version.slug }}">{{ version.slug }}</option>
        {% endfor %}
        </select>
        <input type="submit" value="{% trans "Build version" context "Build is a verb" %}">
      </form>
    </div>
  </div>
{% endif %}
{% endblock %}

{% if project.description %}
<div id="project_description">
  <h3>{% trans "Description" %}</h3>
  <p>
    {{ project.description|restructuredtext }}
  </p>
</div>
{% endif %}

</div>{# END .module #}

<div class="project_details">
  {% include "core/project_detail_right.html" with badge_url=badge_url site_url=site_url %}
</div>{# END .project_details #}

  </div>
</div>
